﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Diagnostics;

namespace CodeSmith.SchemaHelper.Util
{
    public class DBHelper
    {        
        public static DbConnection GetConnection()
        {           
            //string type = string.Format("{0}.{1},{2}", ADONameHelper.ClientNamespace, ADONameHelper.DbConnectionName, ADONameHelper.DbAssembly);
            string type = "Oracle.DataAccess.Client.OracleConnection, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342";
            Type connType = Type.GetType(type);
            if (connType == null)
            {
                return null;
            }

            DbConnection conn = Activator.CreateInstance(connType) as DbConnection;
            //DbConnection conn = new Oracle.DataAccess.Client.OracleConnection();
            return conn;
        }

        public static DbConnection GetConnection(string connectionString)
        {
            DbConnection conn = GetConnection();
            if (conn != null)
            {
                conn.ConnectionString = connectionString;
            }
            return conn;
        }
    }
}


